# pip install requests 安装三方库
import requests # 发送所有类型的 HTTP 请求的 Python 库
if __name__ == '__main__':
    url = 'http://gitbook.cn/'
    headers = {
        'User-Agent': ''
    }
    response = requests.get(url=url, headers=headers)
    response.encoding = 'utf-8' # 设置响应内容的编码方式为 UTF-8，防止中文等非ASCII字符出现乱码问题
    page_text = response.text
    print(page_text)
    with open('d:/项目/python/爬虫/网页/测试.html', 'w', encoding='utf-8') as fp:
       fp.write(page_text)